#pragma once
#include "stdafx.h"
#include "InputClass.h"
#include "Config.h"

class Component;
class InputClass;
class Config;

//This class control the keyboard input, mouse input and joystick input in the game.
//After the game start, Control class will binding keyboard function which needed in 
//this game to InputClass::IsPressedKey with a specificed parameter according to the
//Config class keyboard config information.
class Control : public Component
{
private:
	Control(const Control&);

public:
	typedef boost::shared_ptr<Control> sPtr;
	typedef boost::function<bool()> KeyBoardFunc;
	typedef boost::unordered_map<string,string> KeyMap;
	
	Control();
	~Control();
	void AddedToObject();
	bool Frame();

private:
	void Initial(const Message& msg);
	void SetInputImpl(const Message& msg);
	void BindKeyToFunction(const string&,KeyBoardFunc& );
	void InitialKeyFunction(const string&, const string& );
	void InitialDefaultKey();

private:
	InputClass::sPtr m_input;
	KeyMap m_keyMap;
	KeyBoardFunc m_cameraUp;
	KeyBoardFunc m_cameraDown;
	KeyBoardFunc m_cameraLeft;
	KeyBoardFunc m_cameraRight;
	KeyBoardFunc m_cameraRoundLeft;
	KeyBoardFunc m_cameraRoundRight;
	KeyBoardFunc m_cameraIn;
	KeyBoardFunc m_cameraOut;
	KeyBoardFunc m_escape;
};